package com.java复习.练习一二四答案.demo6;

public class Rectangle extends Shape{
    private int width;
    private int height;

    public Rectangle(int width,int height){
        this.width = width;
        this.height = height;
    }

    @Override
    public void draw() {
        for(int i=0;i<height;i++){
            for(int j=0;j<width;j++){
                System.out.print("* ");
            }
            System.out.println("");
        }
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        if(width>=1 && width<=15){
            this.width = width;
        }else {
            System.out.println("宽度输入错误");
            System.exit(0);
        }
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }
}
